package org.subatu.orm.query.base;

import org.subatu.orm.query.table.CondColumn;
import org.subatu.orm.query.table.QueryColumn;
import org.subatu.orm.query.table.TableDef;

import java.util.*;

public class SqlData {

    // where 和 join 的 别名记录: key为表名, value为别名
    public final Map<String, String> tableAliasMap = new HashMap<>();

    // 查询 部分
    public List<QueryColumn> selectList = new ArrayList<>();
    public StringBuilder selectSql = new StringBuilder();
    public StringBuilder distinct = new StringBuilder();

    // from 部分
    public final List<TableDef> fromTable = new ArrayList<>();
    public final StringBuilder fromSql = new StringBuilder();

    // 连接部分 (含条件)
    public List<TableDef> joinList = new ArrayList<>();
    public StringBuilder joinSql = new StringBuilder();

    // 标志位: 0 join ; 1 where ; 2 having
    public Flag isWhere = Flag.newFlag(0);
    // 查询条件
    public List<CondColumn> whereList = new ArrayList<>();
    public StringBuilder whereSql = new StringBuilder();

    // group by 条件
    public List<QueryColumn> groupByList = new ArrayList<>();
    public StringBuilder groupBySql = new StringBuilder();

    // 聚合列
    public List<CondColumn> havingList = new ArrayList<>();
    public StringBuilder havingSql = new StringBuilder();

    // order By 条件
    public Map<QueryColumn, OrderEnum> orderByList = new LinkedHashMap<>();
    public StringBuilder orderBySql = new StringBuilder();

    // 最终的参数值列表
    public List<Object> valueList = new ArrayList<>();
    // 最后补充的 sql
    public StringBuilder lastSql = new StringBuilder();
}
